package com.uh.calculation.service;

import com.uh.calculation.bean.WarnJiSuanBean;
import com.uh.calculation.inter.Warn;
import com.uh.calculation.inter.bathImp.BatchMaoyiImp;
import com.uh.calculation.inter.imp.*;
import com.uh.microservice.core.dao.JdbcDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class CalculationService {



    @Autowired
    private JdbcDao jdbcDao;
    private Warn warn;

    public  void  test(){
        WarnJiSuanBean warnJiSuanBean   = new WarnJiSuanBean();
        warnJiSuanBean.setJdbcDao(jdbcDao);
        warnJiSuanBean.setSubjectCode("E");
        warnJiSuanBean.setSurveyobjectid("59663461X");
        //贸易-批零 771923153
        //贸易-住餐
        warnJiSuanBean.setWarnEnterpriseRecords(new ArrayList<>());
        String   subjectCode =warnJiSuanBean.getSubjectCode();
        char charAry = subjectCode.toCharArray()[0];
        switch (charAry) {
            case 'B': warn = new GongyeImp();break;//工业
            case 'S': warn = new S_MaoyiImp();break;//贸易
            case 'F': warn = new FuwuImp();break;//服务
            case 'E': warn = new MaoyiImp();break;//贸易
            case '2': warn = new TouziImp();break;//投资
        }
        //warn =new BatchMaoyiImp();
        warn.jisuan(warnJiSuanBean);
    }



    public  void  count(WarnJiSuanBean warnJiSuanBean) {
        try {
            warnJiSuanBean.setJdbcDao(jdbcDao);
            String subjectCode = warnJiSuanBean.getSubjectCode();
            char charAry = subjectCode.toCharArray()[0];
            switch (charAry) {
                case 'B':
                    warn = new GongyeImp();
                    break;//工业
                case 'S':
                    warn = new S_MaoyiImp();
                    break;//贸易
                case 'F':
                    warn = new FuwuImp();
                    break;//服务
                case 'E':
                    warn = new MaoyiImp();
                    break;//贸易
                case '2':
                    warn = new TouziImp();
                    break;//投资
            }
            warn.jisuan(warnJiSuanBean);
        }catch (Exception e) {
        }
    }
}